package org.example.com.controller;

import jakarta.servlet.http.HttpServletResponse;
import org.example.com.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/second")
public class SecondController {

    @RequestMapping("/a")
    public void a(HttpServletResponse response) throws IOException {
        System.out.println("输出");
        PrintWriter writer = response.getWriter();
        writer.print("hello,world!");
    }
    @ResponseBody
    @RequestMapping("/b")
    public String b(){
        return "hello,world!";
    }
    @ResponseBody
    @RequestMapping("/c")
    public int c(){
        return 22;
    }
    @ResponseBody
    @RequestMapping("/d")
    public List<String> d(){
       return Arrays.asList("aa","bb","cc");
    }
    @ResponseBody
    @RequestMapping("/e")
    public User e(){
        User user = new User();
        user.setAge(18);
        user.setName("vv");
        user.setLoves(new String[]{"aa","bb","cc"});
        return user;
    }

}
